package com.cloudcc.mobile.adapter;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cloudcc.mobile.AppContext;
import com.cloudcc.mobile.R;

public class MyChatterIndexPopAdapter extends BaseAdapter{
	private ArrayList<String> list;
	private Context  context;
	public MyChatterIndexPopAdapter(Context  context,ArrayList<String> list){
		this.list=list;
		this.context=context;
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("ResourceAsColor")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if(convertView==null){
			holder=new ViewHolder();
			convertView=LayoutInflater.from(context).inflate(R.layout.chat_index_pop_item,null);
			holder.tv=(TextView)convertView.findViewById(R.id.textView1);
			
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		holder.tv.setText(list.get(position));
		if(AppContext.position==position){
			holder.tv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.chat_pop_progress));
		}else{
			holder.tv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.chat_progress));
		}
		return convertView;
	}
	class ViewHolder{
		private  TextView tv;
	}

}
